package com.yyn.pigeon.controller;


import com.yyn.pigeon.config.R;
import com.yyn.pigeon.entity.Goods;
import com.yyn.pigeon.entity.dto.GoodsCategory;
import com.yyn.pigeon.service.GoodsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 菜品管理 前端控制器
 * </p>
 *
 * @author yyn
 * @since 2023-03-15
 */
@RestController
@RequestMapping("/pigeon/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @ApiOperation("查询所有商品+关键字查询+分类查询")
    @GetMapping("all")
    public R getAll(String keyWord,String category){
        List<Goods> all = goodsService.getAll(keyWord,category);
        return R.success().data("allGoods",all);
    }
    @ApiOperation("根据id查详情")
    @GetMapping("{id}")
    public R getGoodById(@PathVariable String id){
        Goods goodById = goodsService.getGoodById(id);
        return R.success().data("goodById",goodById);
    }



}

